package com.example.treeHole.service.impl;

import com.example.treeHole.dao.ArticleCategoryMapper;
import com.example.treeHole.service.ArticleCategoryService;
import com.example.treeHole.vo.ArticleCategory;
import com.example.treeHole.vo.ArticleReply;
import com.example.treeHole.vo.dto.ArticleCategoryDto;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ArticleCategoryServiceImpl implements ArticleCategoryService {

    @Autowired
    ArticleCategoryMapper articleCategoryMapper;
    @Override
    public List<ArticleCategory> findAll() {
        List<ArticleCategory> articleCategoryList=articleCategoryMapper.findAll();
        return articleCategoryList;
    }

    @Override
    public PageInfo<ArticleCategory> page(ArticleCategoryDto articleCategoryDto) {
        PageHelper.startPage(articleCategoryDto.getPageNum(),articleCategoryDto.getPageSize());
        List<ArticleCategory> articleReplies=articleCategoryMapper.findAll();
        PageInfo<ArticleCategory> of = PageInfo.of(articleReplies);
        return of;
    }

    @Override
    public ArticleCategory findById(String id) {
        ArticleCategory articleCategory = articleCategoryMapper.selectByPrimaryKey(id);
        return articleCategory;
    }
}
